package com.znsd.r_e_m.dao;

import com.znsd.r_e_m.bean.Student;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface StudentMapper {

    @Insert("insert into student(stuName,stuAge,stuSex,stuAddress,updateTime) values(#{stuName},#{stuAge},#{stuSex},#{stuAddress},NOW())")
    @Options(useGeneratedKeys=true,keyProperty="stuId", keyColumn="stu_id")
    public int saveStuden(Student student);

    @Delete("delete from student where stuId=#{sid}")
    public int removeStudent(Integer sid);

    @Update("update student set stuName=#{stuName},stuAge=#{stuAge},stuSex=#{stuSex},stuAddress=#{stuAddress},updateTime=NOW() where stuId=#{stuId}")
    public int updateStudent(Student student);

    @Select("select count(1) from student")
    public int studentCount();
}